<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD><TITLE>Tcl_PrintDouble manual page - Tcl Library Procedures</TITLE>
<link rel="stylesheet" href="../docs.css" type="text/css" media="all">
</HEAD>
<BODY><H2><a href="../contents.htm">Tcl8.6.11/Tk8.6.11 Documentation</a> <small>&gt;</small> <a href="contents.htm">Tcl C API</a> <small>&gt;</small> PrintDbl</H2>
<H3><A HREF="../UserCmd/contents.htm">Tcl/Tk Applications</A> | <A HREF="../TclCmd/contents.htm">Tcl Commands</A> | <A HREF="../TkCmd/contents.htm">Tk Commands</A> | <A HREF="../ItclCmd/contents.htm">[incr Tcl] Package Commands</A> | <A HREF="../SqliteCmd/contents.htm">SQLite3 Package Commands</A> | <A HREF="../TdbcCmd/contents.htm">TDBC Package Commands</A> | <A HREF="../TdbcmysqlCmd/contents.htm">tdbc::mysql Package Commands</A> | <A HREF="../TdbcodbcCmd/contents.htm">tdbc::odbc Package Commands</A> | <A HREF="../TdbcpostgresCmd/contents.htm">tdbc::postgres Package Commands</A> | <A HREF="../TdbcsqliteCmd/contents.htm">tdbc::sqlite3 Package Commands</A> | <A HREF="../ThreadCmd/contents.htm">Thread Package Commands</A> | <A HREF="../TclLib/contents.htm">Tcl C API</A> | <A HREF="../TkLib/contents.htm">Tk C API</A> | <A HREF="../ItclLib/contents.htm">[incr Tcl] Package C API</A> | <A HREF="../TdbcLib/contents.htm">TDBC Package C API</A></H3>
<H3><A NAME="M2">NAME</A></H3>
Tcl_PrintDouble &mdash; Convert floating value to string
<H3><A NAME="M3">SYNOPSIS</A></H3>
<B>#include &lt;tcl.h&gt;</B><BR>
<B>Tcl_PrintDouble</B>(<I>interp, value, dst</I>)<BR>
<H3><A NAME="M4">ARGUMENTS</A></H3>
<DL class="arguments">
<DT><A HREF="../TclLib/Interp.htm">Tcl_Interp</A> <B>*interp</B> (in)<DD>
Before Tcl 8.0, the <B><A HREF="../TclCmd/tclvars.htm">tcl_precision</A></B> variable in this interpreter
controlled the conversion.  As of Tcl 8.0, this argument is ignored and
the conversion is controlled by the <B><A HREF="../TclCmd/tclvars.htm">tcl_precision</A></B> variable
that is now shared by all interpreters.
<P><DT>double <B>value</B> (in)<DD>
Floating-point value to be converted.
<P><DT>char <B>*dst</B> (out)<DD>
Where to store the string representing <I>value</I>.  Must have at
least <B>TCL_DOUBLE_SPACE</B> characters of storage.
<P></DL>
<H3><A NAME="M5">DESCRIPTION</A></H3>
<B>Tcl_PrintDouble</B> generates a string that represents the value
of <I>value</I> and stores it in memory at the location given by
<I>dst</I>.  It uses <B>%g</B> format to generate the string, with one
special twist: the string is guaranteed to contain either a
&ldquo;.&rdquo;
or an
&ldquo;e&rdquo;
so that it does not look like an integer.  Where <B>%g</B> would
generate an integer with no decimal point, <B>Tcl_PrintDouble</B> adds
&ldquo;.0&rdquo;.
<P>
If the <B><A HREF="../TclCmd/tclvars.htm">tcl_precision</A></B> value is non-zero, the result will have
precisely that many digits of significance.  If the value is zero
(the default), the result will have the fewest digits needed to
represent the number in such a way that <B><A HREF="../TclLib/DoubleObj.htm">Tcl_NewDoubleObj</A></B>
will generate the same number when presented with the given string.
IEEE semantics of rounding to even apply to the conversion.
<H3><A NAME="M6">KEYWORDS</A></H3>
<A href="../Keywords/C.htm#conversion">conversion</A>, <A href="../Keywords/D.htm#double-precision">double-precision</A>, <A href="../Keywords/F.htm#floating-point">floating-point</A>, <A href="../Keywords/S.htm#string">string</A>
<div class="copy">Copyright &copy; 1989-1993 The Regents of the University of California.
<BR>Copyright &copy; 1994-1997 Sun Microsystems, Inc.
</div>
</BODY></HTML>
